<?php
$iCat = getValue('iCat','int','GET',0);

$db = new DBQuery;
//Đếm số bản ghi
$total_record = $db->numRecord('SELECT cat_id FROM product WHERE pro_cat_id = '.$iCat);
// khai báo Phân trang
$page_size		= 3;
$page_current   = 0;
$action = getValue('action','str','POST','');
if($action === 'paging'){
    $page_current = getValue('page_current','int','POST',0);
}
if($total_record%$page_size){
	$page_total = ($total_record - $total_record%$page_size)/$page_size+1;
}
else
    $page_total = $total_record/$page_size;
//Phân trang


//Select tên của thư mục
$catname = $db->loadResult('SELECT cat_name FROM categories WHERE cat_id = '.$iCat);
//Select các bản ghi
$catpro = $db->query('SELECT   pro_id,
                                pro_name,
                                pro_cat_id,
                                pro_information,
                                pro_information_summary,
                                pro_image
                                FROM product 
                       WHERE pro_cat_id = '.$iCat. '
                       LIMIT '.$page_current.','.$page_size);


?>
<style>
.wrap1{
    background:url('/images/site_image/bg1.jpg');
    background-size:100% 100%;
}
.catalogTitle {
    margin:10px 168px;
    background:rgba(0,0,0,0.6);
    border-radius: 10px;
    height:46px; line-height:46px;
}
.catalogTitle h3 {
    font-size:24px;
    color:#fff;
    text-align: center;
}
.wrapContent_pros {
	width:760px;
	margin-left:75px;
	background: none repeat scroll 0 0 rgba(255, 255, 255, 0.3);
	overflow:hidden;
	border-radius: 10px;
}
.detailsPro {
	width:200px;
	height:200px;
	margin-left:30px;
	float:left;
}
.detailsPro > img {
	width:180px;
	height:150px;
	margin-left:10px;
	margin-top:10px;
	float:left;
}
.detailsPro > h2  {
	font-size:14px;
	text-align:center;
}
</style>
<div class="catalogTitle">
    	<h3><?php echo $catname ?></h3>
</div>
<div class="wrapContent_pros">
    
    <?php if($catpro) foreach($catpro as $apro):?>
    	<div class="detailsPro">
    		<img class="" src="<?php echo ($apro['pro_image']) ? $path_img_product . $apro['pro_image'] : $path_img_site.'noimages.png'?>"/>
    		<h2 class=""><a href="<?=generate_detail_url('products',$apro)?>"><?php echo $stringhelper->CropWord($apro['pro_name'],10)?></a></h2>
    	</div>
    <?php endforeach; 
        else echo 'Không có sản phẩm nào';?>
    
</div>
<script>
$('.mainContent2').jScrollPane();
var page_current = 1;
var page_total = <?php echo $page_total?>;
var data = {name:'page_cat_pros'};
$('.btn_content').click(function(){
    if(page_current < page_total){
        var iCat = '<?php echo base64_encode($iCat) ?>';
        data.iCat = iCat;
        data.page_current = page_current;
 //       loadModule('.mainContent2',data,false);
        $.ajax({
            type:'POST',
            url:'ctrlmod',
            data:data,
            success:function(result){
                $('.jspPane').append(result);
                $('.mainContent2').jScrollPane();
            }
        })
        $('.mainContent2').jScrollPane();
        page_current++;    
    }
    else alert('Đây là trang cuối');
    
});

</script>